#ifndef __tree_H__
#define __tree_H__

#define datatype char

typedef struct TreeNode
{
     datatype data;
     struct TreeNode *firstChild;  // leftchild
     struct TreeNode *nextSibling; // rightchild      //sibling:兄弟姊妹
} TreeNode;

typedef struct Tree
{
     TreeNode *root;
     datatype refvalue;
} Tree;

void Init(Tree *tree, datatype ref);

void Create(Tree *tree, char *str);
void Create_(Tree *tree, TreeNode **node, char **str); //以这棵树等价的二叉树来创建

TreeNode *Root(Tree *tree); //返回树的根

TreeNode *firstChild(TreeNode *node); //求结点的孩子结点

TreeNode *nextSibling(TreeNode *node); //求结点的兄弟结点

TreeNode *Find(Tree *tree, datatype key); //与二叉树的求解方式相同

TreeNode *Find_(TreeNode *node, datatype key); //从和树等价的二叉树下手

TreeNode *Parent(Tree *tree, TreeNode *node); //求结点的父结点
TreeNode *Parent_(TreeNode *root, TreeNode *node);

void PreOrder(TreeNode *root);

#endif
